package com.mapper;

import com.entity.Flower;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FlowerMapper {
    // 查询所有花
    @Select("select * from flowers;")
    List<Flower> selectAllFlowers();

    // id 查询一朵花
    @Select("select * from flowers where flowerId = #{flowerId};")
    Flower selectOneFlowerById(int id);

    // id 删除一朵花
    @Delete("delete from flowers where flowerId = #{flowerId};")
    int deleteOneFlowerById(int id);

    // name 查询一朵花
    @Select("select * from flowers where flowerName like '%${flowerName}%';")
    List<Flower> selectOneFlowerByName(String flowerName);

    // 新增一朵花
    @Insert("insert into flowers (flowerName, category, price) values (#{flowerName},#{category},#{price});")
    int insertOneFlower(Flower flower);

    // 修改一朵花
    @Update("update flowers set flowerName = #{flowerName},category = #{category},price = #{price} where flowerId = #{flowerId};")
    int updateOneFlower(Flower flower);
}
